package com.zrwl.poscloud.xo.service.impl;
import com.zrwl.poscloud.base.entity.EmployeeRecord;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zrwl.poscloud.base.enums.EStatus;
import com.zrwl.poscloud.base.superI.SuperServiceImpl;
import com.zrwl.poscloud.commons.utils.ResultUtil;
import com.zrwl.poscloud.commons.utils.StringUtils;
import com.zrwl.poscloud.xo.global.MessageConf;
import com.zrwl.poscloud.xo.global.SQLConf;
import com.zrwl.poscloud.xo.global.SysConf;
import com.zrwl.poscloud.xo.mapper.EmployeeDeptRecordMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import com.zrwl.poscloud.xo.mapper.EmployeeRecordMapper;
import com.zrwl.poscloud.xo.service.EmployeeRecordService;
import com.zrwl.poscloud.xo.vo.EmployeeRecordVO;

import javax.annotation.Resource;

/**
 * 人员简历 服务实现类
 *
 * @author 刘思童 AutoGenerate
 * @date 2023-02-27
 */
@Service
public class EmployeeRecordServiceImpl extends SuperServiceImpl<EmployeeRecordMapper,EmployeeRecord> implements EmployeeRecordService {

    @Autowired
    private EmployeeRecordService employeeRecordService;
    @Resource
    private EmployeeRecordMapper employeeRecordMapper;
    @Override
    public IPage<EmployeeRecordVO> getPageList(EmployeeRecordVO employeeRecordVO){
       Page<EmployeeRecord> page = new Page<>();
       page.setCurrent(employeeRecordVO.getCurrentPage());
       page.setSize(employeeRecordVO.getPageSize());
       IPage<EmployeeRecordVO> pageList = employeeRecordMapper.getPageList(page,employeeRecordVO);
       List<EmployeeRecordVO> list = pageList.getRecords();
       pageList.setRecords(list);
       return pageList;
}
    @Override
    public List<EmployeeRecord> getAllList(EmployeeRecordVO employeeRecordVO){
        QueryWrapper<EmployeeRecord> queryWrapper = new QueryWrapper<>();
        queryWrapper.ne(SQLConf.STATUS, EStatus.DISABLED);
        queryWrapper.orderByAsc(SQLConf.CREATE_TIME);
        List<EmployeeRecord> list = employeeRecordService.list(queryWrapper);
        return list;
}
    @Override
    public String add(EmployeeRecordVO employeeRecordVO){
        EmployeeRecord entity = new EmployeeRecord();
        BeanUtils.copyProperties(employeeRecordVO, entity, SysConf.STATUS);
        entity.insert();
        employeeRecordVO.setUid(entity.getUid());
        return ResultUtil.successWithMessage(MessageConf.INSERT_SUCCESS);}
    @Override
    public String edit(EmployeeRecordVO employeeRecordVO){
        EmployeeRecord entity = employeeRecordService.getById(employeeRecordVO.getUid());
        BeanUtils.copyProperties(employeeRecordVO, entity);
        entity.updateById();
        return ResultUtil.successWithMessage(MessageConf.UPDATE_SUCCESS);
}
    @Override
    public String delete(EmployeeRecordVO employeeRecordVO){
        EmployeeRecord entity = employeeRecordService.getById(employeeRecordVO.getUid());
        entity.setStatus(EStatus.DISABLED);
        entity.updateById();
        return ResultUtil.successWithMessage(MessageConf.UPDATE_SUCCESS);
}

}
